package org.lboot.ufos.test;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.lboot.ufos.client.S3Client;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("s3")
@AllArgsConstructor
@Api(tags = "版本方法测试")
public class S3VersionTestController {
    S3Client s3Client;
    @GetMapping("object/{bucketName}/{objectName}/version")
    @ApiOperation(value = "对象版本信息")
    public Object objectInfo(@PathVariable("bucketName") String bucketName, @PathVariable("objectName") String objectName){
        return s3Client.listObjectVersions(bucketName, objectName);
    }

    @PostMapping("enableVersion")
    @ApiOperation(value = "开启版本控制")
    public Object enableVersion(@RequestParam("bucketName") String bucketName){
        s3Client.enableVersion(bucketName);
        return "开启成功";
    }
}
